import utils.EmptyListException;
import utils.PosIllegalityException;

public class Test {
    public static void main(String[] args) {
        MyArrayList myArrayList = new MyArrayList();

        try {
            myArrayList.add(0,11);
            myArrayList.add(1,21);
            myArrayList.add(2,31);
            myArrayList.add(3,41);
            myArrayList.add(4,51);
            myArrayList.display();

            myArrayList.add(5,61);
            //myArrayList.add(7,999);
            myArrayList.display();
//            myArrayList.clear();

            myArrayList.set(0,188);
            myArrayList.display();
            System.out.println("开始remove");
            myArrayList.remove(188);
            myArrayList.display();
        }catch (PosIllegalityException e) {
            e.printStackTrace();
            System.out.println("add-pos位置异常！");
        }catch (EmptyListException e) {
            e.printStackTrace();
        }finally {
            System.out.println("清空顺序表");
            myArrayList.clear();
            myArrayList.display();
        }

    }
    public static void main1(String[] args) {
        MyArrayList myArrayList = new MyArrayList();
        myArrayList.add(1);
        myArrayList.add(2);
        myArrayList.add(3);
        myArrayList.add(4);
        myArrayList.display();
        System.out.println(myArrayList.size());
        int ret = myArrayList.indexOf(2);
        System.out.println(ret);
        System.out.println("============");

        try {
            int i = myArrayList.get(3);
            System.out.println(i);
        }catch (EmptyListException e) {
            e.printStackTrace();
        }catch (PosIllegalityException e) {
            e.printStackTrace();
        }

    }
}
